﻿using AT.Data.Core.SC_Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace apitest.Application.Services
{
    public class SrService : IDynamicApiController
    {
        ISqlSugarClient _db;
        ISqlSugarClient _testDb;

        public SrService(ISqlSugarClient db)
        {
            _db = db;
            _testDb = db.AsTenant().GetConnection("test");
        }

        [NonUnify]
        public async Task<dynamic> CreateVueFileByModel()
        {
            //var tableInfo = _db.DbMaintenance.GetTableInfoList().FirstOrDefault();
          var list=  _db.DbMaintenance.GetColumnInfosByTableName("SC_InquiryQuotation");
            var sb = new StringBuilder();
            foreach (var item in list) {
                var name = ReWriteName(item.DbColumnName);
                sb.AppendLine($@"<el-table-column width=""100"" align=""center"" label=""{item.ColumnDescription}"" prop=""{name}"" :show-overflow-tooltip=""true""/> ");
            }
            return sb.ToString();
            //return _db.DbMaintenance.GetDataBaseList().FirstOrDefault();
        }

        string ReWriteName(string name)
        {
            var first=name.First().ToString().ToLower();
            return first+name.Substring(1);
        }
    }
}
